'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 每日任务
 * @author sundbcn@gmail.com (sun debing)
 */

var dataApi = require('../libs/dataApi');

/**
 * 获取任务奖励活跃度列表
 */
exports.getActiveRewardList = function (active_id) {
    return dataApi.daily_reward.findById(active_id);
};

/**
 * 根据id获取任务对应奖励活跃度
 * @param  {[type]} daily_id [description]
 * @param  {[type]} lv       [description]
 * @return {[type]}          [description]
 */
exports.getDailyTaskActive = function (daily_task_id) {
    var daily_active_conf = dataApi.daily.findById(daily_task_id);
    if (daily_active_conf) {
        return parseInt(daily_active_conf.activity);
    }
    return 0;
};

/**
 * 获取任务奖励
 */
exports.getRewardList = function (daily_task_id) {
    return dataApi.daily.findById(daily_task_id);
};

/**
 * 获取金币奖励
 * @param  {[type]} daily_id [description]
 * @param  {[type]} lv       [description]
 * @return {[type]}          [description]
 */
exports.getGoldReward = function (daily_id, lv) {
    var hero_lv_conf = dataApi.hero_lvl.findById(lv);
    var daily_conf = dataApi.daily.findById(daily_id);
    if (!hero_lv_conf || !daily_conf) {
        console.error('获取金币奖励 type can not found:' + daily_id);
        return 0;
    }
    return parseInt(hero_lv_conf.daily_gold * daily_conf.gold_ratio);
};

/**
 * 获取经验奖励
 * @param  {[type]} daily_id [description]
 * @param  {[type]} lv       [description]
 * @return {[type]}          [description]
 */
exports.getExpReward = function (daily_id, lv) {
    var hero_lv_conf = dataApi.hero_lvl.findById(lv);
    var daily_conf = dataApi.daily.findById(daily_id);
    if (!hero_lv_conf || !daily_conf) {
        console.error('dailyConf type can not found:' + daily_id);
        return 0;
    }
    return parseInt(hero_lv_conf.daily_exp * daily_conf.exp_ratio);
};
